/**   
 * 项目名：phms3
 * 日期：    2019-11-22 17:31:06  
 * Copyright (c) 2015- HTSC-版权所有     
 */

package com.joysuch.wwyt.mh.repository;

import java.util.List;

import com.joysuch.wwyt.mh.entity.MhAlarmRule;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

/**
 * MhMajorHazardDao
 * 
 */
public interface MhAlarmRuleDao extends JpaRepository<MhAlarmRule, Long>, QuerydslPredicateExecutor<MhAlarmRule> {

    public Page<MhAlarmRule> findAll(Specification<MhAlarmRule> spec, Pageable pageable);

    public MhAlarmRule save(MhAlarmRule bean);

    public void delete(MhAlarmRule bean);

    public List<MhAlarmRule> findByDefaultConfig(String defaultConfig);

    public MhAlarmRule findByDefaultConfigAndLevel(String defaultConfig, Integer level);

    public MhAlarmRule findByMonitoringPointIdAndLevel(Long pid, Integer level);

    public List<MhAlarmRule> findByMonitoringPointId(Long pid);

    @Query("select distinct(monitoringPointId) from MhAlarmRule where monitoringPointId != null")
    List<Long> findMonitorPointIdsHasRules();
}
